{extends file="parent/layout.tpl"}
{block name=title}{$title}{/block}
{block name=head}{/block}
{block name=body}
<table>
    <tr>
        <td><h1>List of Achievements ({count($achievements)})</h1></td>
    </tr>
    <tr>
        <td><form action="">
                Search Achievements: <input type="text" name="searchquery"  value="{$this->input->get('searchquery')}"/><br/>
             </form>
        </td>
    </tr>
</table>
<table>
    <tr>
        
        <td><a href={if $sort_by == 'date_created' && $sort_order == 'asc'} "/browse/{$uri}/date_created/desc" {else} "/browse/{$uri}/date_created/asc" {/if}>Date</a></td>
        <td><a href={if $sort_by == 'points' && $sort_order == 'asc'} "/browse/{$uri}/points/desc" {else} "/browse/{$uri}/points/asc" {/if}>Points</a></td>
        <td><a href={if $sort_by == 'category_id' && $sort_order == 'asc'} "/browse/{$uri}/category_id/desc" {else} "/browse/{$uri}/category_id/asc" {/if}>Category</a></td>
        <td><a href={if $sort_by == 'title' && $sort_order == 'asc'} "/browse/{$uri}/title/desc" {else} "/browse/{$uri}/title/asc" {/if}>Title</a></td>
    </tr>
</table>
<table>
    <tr>
        <td><h3>Choose Achievement Category: </h3></td>
    </tr>
    <tr>
        <td>
            <li><a href="/browse/all">All</a></li>
        {foreach $allCategories as $category}
           <li><a href="/browse/{strtolower($category->title)}">{$category->title}</a></li>
        {/foreach}
        </td>
    </tr>
</table>


    {if !empty({$notice})}
        <div class="notice">
            <p>{$notice}</p>
        </div>
    {/if}
    {if $achievements == NULL}
        <p> No Achievements available! </p>
    {/if}
    <ul class="blankList">
        {foreach $achievements as $achievement}
            <li>
                <div><span class="title">{$achievement->achievementTitle}</span> ({$achievement->achievementPoints}) - <a class="button blue" href="/profile/add_todo/{$achievement->achievementId}">+ Add</a> {if $achievement->achievementDateCreated > $global_userData.lastOnline}<span class="new">New</span>{/if}</div>
                <div><span class="description">{$achievement->achievementDescription}</span></div>
                <div><a href="#">{$achievement->achievementCategoryName}</a></div>
            </li>
        {/foreach}
    </ul>
    {/block}